# #!/usr/bin/env python3
# from bottle import get,post,run,request,template
# @get("/")
# def index():
#     return template("index")
# @post("/cmd")
# def cmd():
#     print("按下了按钮: "+request.body.read().decode())
#     #return "OK"
# run(host="0.0.0.0",port="8080")
# import time
# from pykeyboard import *
# from pymouse import *
# m = PyMouse()  # 建立鼠标对象
# k = PyKeyboard()  # 建立键盘对象
#
# time.sleep(1)
# location1 = m.position()
# time.sleep(1)
# location2 = m.position()
#
# m.click(location1[0], location1[1])
# k.tap_key('w')
# m.click(location2[0], location2[1])


import pygr
import cv2
import time
from base import Keycode, Event
import pyautogui


if __name__ == '__main__':
    pad = pygr.PyGR(size = (480, 320), verbose = True)
    #pad = pygr.PyGR(size = (480, 320))
    pad.show()
    while cv2.waitKey(10) not in [Keycode.ESCAPE, Keycode.Q, Keycode.q]:
        event = pad.get_event()
        print("Event:", event.type, "Tip:", event.tip)
        if event.type == Event.FIVE : # 手势五, 向下滚动
            pyautogui.scroll(-30) # scroll down 10 "clicks"
        elif event.type == Event.FOUR :# 手势四, 向上滚动
            pyautogui.scroll(30) # scroll up 10 "clicks"
        time.sleep(0.1)